package com.my.internetplus.service;


import com.my.internetplus.dao.AddressDao;
import com.my.internetplus.dao.UserDao;
import com.my.internetplus.model.Address;
import com.my.internetplus.model.User;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class AddressService {

    @Resource
    private UserDao userDao;
    @Resource
    private AddressDao addressDao;

    public void addAddress(String name,String phone,String gpsAddr,String describe,String openid){
        addressDao.addAddress(describe,name,userDao.selectUserByOpenId(openid).getUserId(),
                Integer.parseInt(phone),gpsAddr);
    }

    public List<Address> getAddressList(int userid){
        return addressDao.getAddressList(userid);
    }
    public void updateAddress(String name,String phone,String gpsAddr,String describe,int addid){
        addressDao.updateAddress(name,phone,gpsAddr,describe,addid);
    }
    public void delectAddress(int addid){
        addressDao.delectAddress(addid);
    }
}
